<template>
	<view>
		<view class="goodslist-item" @click="onClickHandler">
      <image :src="goods.goods_small_logo || defaultPic"></image>
      <view class="item-left">
        <view class="item-text">{{goods.goods_name}}</view>
        <view class="item-price">￥{{goods.goods_price|toFixed}}</view>
      </view>
    </view>
	</view>
</template>

<script>
	export default {
    filters:{
      toFixed(num){
        return Number(num).toFixed(2);
      },
    },
    props:{
      goods: {
        type: Object,
        default: {},
      }
    },
		data() {
			return {
				// 默认的空图片
				defaultPic: 'https://img3.doubanio.com/f/movie/8dd0c794499fe925ae2ae89ee30cd225750457b4/pics/movie/celebrity-default-medium.png',
			};
		},
    methods:{
      onClickHandler() {
        this.$emit("click")
      }
    },
	}
</script>

<style lang="scss">
.goodslist-item{
    display: flex;
    padding: 20rpx;
    margin: 0 10rpx;
    border-bottom: 1rpx solid #D3D3D3;
    image{
      height: 200rpx;
      width: 320rpx;
    }
    .item-left{
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      margin-left: 40rpx;
      font-weight: bold;
      .item-text{
        font-size: 14px;
      }
      .item-price{
        font-size: 16px;
        color: #C00000;
      }
    }
  }
</style>
